package com.yonyou.pmclouds.safeinspection.process;

import com.yonyou.pmclouds.basecom.bp.processor.SingleProcessor;
import com.yonyou.pmclouds.basecom.exception.BusinessException;
import com.yonyou.pmclouds.inspectitem.entity.InspectItemVO;
import com.yonyou.pmclouds.inspectitem.rmiitf.InspectItemService;
import com.yonyou.pmclouds.safeinspection.entity.SafeInspectionVO;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author 徐老板
 * @date 2020/4/21   16:26
 */
@Component
public class InspectitemaddAfterProcess implements SingleProcessor<SafeInspectionVO> {
    @Resource
    private InspectItemService inspectItemService;

    @Override
    public void process(SafeInspectionVO vo, SafeInspectionVO orig) throws BusinessException {
        if (vo!=null){
            InspectItemVO[] inspectItemVOS = vo.getInspectItemVOS();
            if (inspectItemVOS!=null){
                for (InspectItemVO inspectItemVO : inspectItemVOS) {
                    //分表的时候设置主外键关系
                    inspectItemVO.setPk_bill((vo.getPk_safetypatrol()));
                    inspectItemVO.setPk_project(vo.getPk_project());
                }

                //这个是新方法注意记一下
                inspectItemService.add(inspectItemVOS, vo);
            }
        }
    }
}
